<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath(); 
String strUserId = request.getSession().getAttribute("stxtUName").toString();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  	<style type="text/css" media="all">   
	    .allow-float {clear:none!important;} /* 允许该元素浮动 */  
	    .stop-float {clear:both!important;} /* 阻止该元素浮动 */  
	   	.icon-first {float:left;}   
	   	.icon-choosed {float:left;padding:5 0 0 5px;}
	    .icon-second {float:left;padding:0 0 0 20px;} 
	    .win-first {float:left;}   
	    .win-second {float:left;padding:0 0 0 20px;}   
	   	.standby-yes {float:left;}   
	    .standby-no {float:left;padding:0 0 0 20px;}   
	    .age-field {float:left;padding:0 0 0 58px;*padding:0 0 0 50px!important;*padding:0 0 0 50px;}   
	</style> 
  
    <base href="<%=basePath%>"> 
    <link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/ext-all.css">  
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/ext/resources/css/edit-grid.css">  
	<script type="text/javascript" src="<%=path%>/js/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/ext-all.js"></script>
	<script type="text/javascript" src="<%=path%>/js/ext/DWRTreeLoader.js"></script> 
	<script type="text/javascript" src="<%=path%>/js/ext/query-dwr-proxy.js"></script>	
	<script type="text/javascript" src="<%=path%>/js/ext/ext-lang-zh_CN.js"></script>
	<script type='text/javascript' src='/btsm/dwr/interface/JSystemWeb.js'></script>
	<script type='text/javascript' src='/btsm/dwr/engine.js'></script>
	<script type='text/javascript' src='/btsm/dwr/util.js'></script>	 
  </head>
<body> 	 
	<div id="menuContent"/>   
<script type="text/javascript">
 

Ext.onReady(function(){
	var viewport = new Ext.Viewport({
		layout:'border',
		frame:true,
		items:[ 
			{
				region: 'center',
				contentEl: 'menuContent',
				margins:'110 30 30 5',
				split: true,
				border: true	
			}]
		});
		
	
	var menuForm = new Ext.FormPanel({
        labelWidth: 150,
        frame:true,
        title: '修改密码',   
        defaultType: 'textfield',
		//buttonAlign:'left',
        items: [
				{
					inputType: 'password', 
					fieldLabel : "原密码",
					allowBlank : false,
					name : "oldPassword",
					width:160,
					blankText :'请输入原密码'	
				},{
					xtype : 'textfield',
					inputType: 'password', 
					fieldLabel : "密码",
					allowBlank : false,
					name : "passwd",
					width:160,
					blankText :'请输入密码'	
				},{
					xtype : 'textfield',
					inputType: 'password', 
					fieldLabel : "密码确认",
					allowBlank : false,
					name : "passwdTwo",
					width:160,
					blankText :'请输入确认密码'		
				}
        ],
        buttons: [
				{
					text: '保存',
					handler:saveMenuInfo
				},{
					text: '取消',
					handler:function()
					{
						isSelected = false ;
						menuForm.getForm().reset(); 
					}
				}]
    });

    menuForm.render("menuContent");
		
	
	function saveMenuInfo()
	{
		if (!menuForm.getForm().isValid())
			return;	
		var form = menuForm.getForm().getValues(false);
		 
		if(form.passwd != form.passwdTwo)
		{
			Ext.Msg.alert("提示","确认密码与第一次密码不一致!");
			return;
		} 
		
		var userId = '<%=strUserId%>'	
		JSystemWeb.isAvialable(userId,form.oldPassword,false,function(data)
		{
			if(data)
			{
				JSystemWeb.updatePassword(userId,form.passwdTwo,function(data)
				{
					if(data)
					{
						Ext.Msg.alert('成功',"操作成功！"); 
					}else
					{
						Ext.Msg.alert("失败","操作失败!");
					}																
				})
			}else
				Ext.Msg.alert("失败","原密码不对，请重新输入!");
		})
	
	}
	 	
	
})

</script>
	
</body>
</html>